#######################################################################
#Name of code file: create_israel_map.R

#Data In: israel_map.csv

#Data Out: Figure A2
######################################################################

#Load Packages------

## If you don't have packages installed, uncomment and install
## install.packages("ggplot2")

library("ggplot2")

## On the computer used to generate the results of this script, below is what is
## printed to the console when sessionInfo() is run
## sessionInfo()

## sessionInfo()
## R version 4.1.2 (2021-11-01)
## Platform: aarch64-apple-darwin20 (64-bit)
## Running under: macOS Monterey 12.1

## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libRlapack.dylib

## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base

## other attached packages:
## [1] ggplot2_3.3.5

## loaded via a namespace (and not attached):
##  [1] fansi_0.5.0      withr_2.4.3      assertthat_0.2.1 dplyr_1.0.7
##  [5] crayon_1.4.2     utf8_1.2.2       grid_4.1.2       R6_2.5.1
##  [9] DBI_1.1.1        lifecycle_1.0.1  gtable_0.3.0     magrittr_2.0.1
## [13] scales_1.1.1     pillar_1.6.4     rlang_0.4.12     generics_0.1.1
## [17] vctrs_0.3.8      ellipsis_0.3.2   glue_1.5.1       purrr_0.3.4
## [21] munsell_0.5.0    compiler_4.1.2   pkgconfig_2.0.3  colorspace_2.0-2
## [25] tidyselect_1.1.1 tibble_3.1.6


#Set Working Directory - uncomment and set to replication folder
## setwd("folder")


#Read data----
isr_df <- read.csv("data/israel_map.csv")

#Plot Triangle Localities-----
##Set map theme----
ditch_the_axes <- theme(
 legend.position = "none",
 text = element_text(size = 9, family = "Palatino"),
 axis.text = element_blank(),
 axis.line = element_blank(),
 axis.ticks = element_blank(),
 panel.border = element_blank(),
 panel.grid = element_blank(),
 axis.title = element_blank()
)

## Create Map----
ggplot(isr_df, aes(long, lat, group = group,
                   fill = as.factor(triangle),
                   color = "white")) +
 geom_polygon(colour = "grey85",
              size = 0) +
 coord_equal() +
 scale_fill_manual(values = c("grey80", "firebrick3"))+
 scale_color_manual(values = "white")+
 ggtitle("") +
 theme_bw() +
 ditch_the_axes
ggsave("plots/figure_A2.pdf",  width = 5, height =5)
